package com.captain.special.链表;

import com.captain.leetcode.链表.ListNode;

/**
 * Des:
 *
 * @author XL
 * @Date 2022/4/1 23:46
 */
public class 进制链表转整数1290 {
    public static void main(String[] args) {
        int value = new 进制链表转整数1290().getDecimalValue(ListNode.getInstance());
        System.out.println(value);


    }

    public int getDecimalValue(ListNode head) {
        StringBuilder builder = new StringBuilder();
        while (head != null) {
            builder.append(head.val);
            head = head.next;
        }
        //前面为表示的进制数 / 3:基数
        return Integer.valueOf(builder.toString(), 3);
    }
}
